package sreal.advice;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;
import sreal.annotation.Checker;

import java.lang.annotation.Retention;

@Aspect
@Component
public class DoAdvice {
    @Pointcut("@annotation(value)")
    public void pointcut(Checker value){}
//    @Before(value = "pointcut()")
//    public void doBefore(){
//        System.out.println("切点之前运行");
//    }
//    @After(value = "pointcut()")
//    public void deAfter(){
//        System.out.println("切点之前运行");
//    }
    @Around("pointcut(value)")
    public Object doAround(ProceedingJoinPoint joinPoint,Checker value){
        Object result=null;
        System.out.println("切点之前运行");
        try {
            result = joinPoint.proceed();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        System.out.println("切点之后运行");
        return result;

    }
}
